package com.tssup.fesco.b2c;

import com.tssup.fesco.service.SchedulService;
import com.tssup.fesco.util.HttpClientHelper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
import com.xxl.job.core.log.XxlJobLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * Created by franco.cheng on 2017/6/6.
 */
@JobHander(value="SalesVolumeStatisticsJob")
@Service
public class SalesVolumeStatisticsJob extends IJobHandler {

    private Logger logger =  LoggerFactory.getLogger(this.getClass());

    @Autowired
    SchedulService schedulService;

    @Override
    public ReturnT<String> execute(String... params) throws Exception {
        try {
            XxlJobLogger.log("商品日销量统计定时任务开始");
            schedulService.salesVolumeStatistics();
            XxlJobLogger.log("商品日销量统计定时任务结束");
            
        } catch ( Exception e ){
            logger.error("商品日销量统计定时任务结束", e);
            XxlJobLogger.log("商品日销量统计定时任务结束");
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
